package com.blog.controller;

import com.blog.pojo.ResultResponse;
import com.blog.pojo.User;
import com.blog.service.FollowService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
public class FollowController {
    @Autowired
    private FollowService followService;

    //查询当前用户关注的人的信息
    @GetMapping("/focus/currentUser")
    public ResultResponse listFocusById(){
        List<User> userList = followService.listFocusById();
        return ResultResponse.success(userList);
    }

    //查询当前用户粉丝信息
    @GetMapping("/follows/currentUser")
    public ResultResponse listFollowsById(){
        List<User> userList = followService.listFollowsById();
        return ResultResponse.success(userList);
    }

    //关注
    @PostMapping("/focus")
    public ResultResponse insertFollow(@RequestParam Integer userId){
        followService.insertFollow(userId);
        return ResultResponse.success();
    }

    //取消关注
    @DeleteMapping("/focus/{id}")
    public ResultResponse deleteFollow(@PathVariable("id") Integer userId){
        followService.deleteFollow(userId);
        return ResultResponse.success();
    }
}
